package com.canbot.u05.activity.customvoice.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.canbot.u05.R;
import com.canbot.u05.activity.customvoice.bean.CustomDialogExcelData;

import java.util.List;

/**
 * Created by liu.heng on 2018/5/25.
 */

public class CustomDialogScreenAdapter extends RecyclerView.Adapter<CustomDialogScreenAdapter.ViewHolder> {

        private Context context;

        private List<CustomDialogExcelData> mList;

        private LayoutInflater mLayoutInflater;

        public CustomDialogScreenAdapter(Context context, List<CustomDialogExcelData> list) {
                this.context = context;
                this.mList = list;
                mLayoutInflater = LayoutInflater.from(context);
        }

        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                View inflate = mLayoutInflater.inflate(R.layout.custom_dialog_screen_item, parent, false);
                return new ViewHolder(inflate, viewType);
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
                holder.mTextView_qustion.setText(mList.get(position).getQustion_str());
                holder.mTextView_answer1.setText(mList.get(position).getTts_text());
                final String btn_id = String.valueOf(position + 1);
                holder.mButton_id.setText(btn_id);
        }

        @Override
        public int getItemCount() {
                return mList == null ? 0 : mList.size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {

                private TextView mTextView_qustion;

                private TextView mTextView_answer1;

                private Button mButton_id;

                public ViewHolder(View view,int position) {
                        super(view);
                        mTextView_qustion = (TextView) view.findViewById(R.id.qustion_text);
                        mTextView_answer1 = (TextView) view.findViewById(R.id.answer_text1);
                        mButton_id = (Button) view.findViewById(R.id.id_btn);
                }
        }
}
